using System;
using System.Collections.Generic;
using System.Text;
using Entity;
using ECommerce.Library.ECommerce;

namespace AutoGear.BLL
{
    public class CreditCard : ICreditCard
    {
        public CreditCard(string cardType, string cardNumber, string cardCode, DateTime expireDate)
        {
            this._cardType = cardType;
            this._cardNumber = cardNumber;
            this._cardCode = cardCode;
            this._expireDate = expireDate;
        }
        public CreditCard(int cardId, string cardType, string cardNumber, string cardCode, DateTime expireDate)
        {
            this._cardId = cardId;
            this._cardType = cardType;
            this._cardNumber = cardNumber;
            this._cardCode = cardCode;
            this._expireDate = expireDate;
        }
        public void Save()
        {
            CardId = TblCreditCard.CreateNewTblCreditCard(CardType, Imgalib.Utility.Cryptography.EncryptStringAES(CardNumber), CardCode, ExpireDate);
        }

        public void Delete()
        {
            if(CardId > 0)
                TblCreditCard.DeleteTblCreditCard(CardId);
        }

        #region ICreditCard Members

        private int _cardId;
        public int CardId
        {
            get { return this._cardId; }
            set { this._cardId = value; }
        }

        private string _cardType;
        public string CardType
        {
            get { return this._cardType; }
            set { this._cardType = value; }
        }

        private string _cardNumber;
        public string CardNumber
        {
            get { return this._cardNumber; }
            set { this._cardNumber = value; }
        }

        private string _cardCode;
        public string CardCode
        {
            get { return this._cardCode; }
            set { this._cardCode = value; }
        }

        private DateTime _expireDate;
        public DateTime ExpireDate
        {
            get { return this._expireDate; }
            set { this._expireDate = value; }
        }

        #endregion
    }
}
